package cn.com.sbell.vss.csg.vap;


import org.dom4j.Element;

import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;
import cn.com.sbell.vss.VssConstants;

public class RequestVsUpgrade extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient, PropertiesHolder holder, Element root) {
		String fileURL = holder.getStrProperty("fileURL");		
		if(fileURL==null){
			throw new VssException(VssConstants.CODE_REQUIRED,new String[]{"csg.fileURL"});
		}
		Integer timeout = holder.getIntProperty("timeout");
		if(timeout==null){
			throw new VssException(VssConstants.CODE_REQUIRED,new String[]{"csg.timeout"});
		}
		String deviceId = holder.getStrProperty("deviceId");
		vsClient.requestVsUpgrade(fileURL,timeout.intValue(),deviceId);
		return root;
	}
}
